#!/usr/bin/env python
# encoding: utf-8 
'''
Created on 2017年2月6日

@author: sunying
'''
from utils_qa import token
if __name__ == '__main__':
    env = 'qa'
    print env
    auth_dict = token.get_auth(env)
        #auth_dict = token.get_auth('qa')
    url_prefix = auth_dict['url']
    auth_data = auth_dict['auth']
    access_token = token.get_access_token(url_prefix,auth_data)
    url_suffix = "/v2/service/tasks_join_ent_groups.json" 
    file = open('service.txt')
    task_ids = file.read()
    print task_ids,type(task_ids)
    file.close()
    task_list = task_ids.split()
    print task_list
    for task_id in task_list:
        post_dict = [{"groups":"2205","tasks":task_id}]
        print(post_dict)
        actual = token.pycurl_post(url_prefix, url_suffix, access_token, post_dict)
        print  actual